package com.xuetang9.t9.xinhuaxia.mappers;

import com.xuetang9.t9.xinhuaxia.beans.User;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface UserMapper extends Mapper<User> {

    @Select("select * from user where u_userName=#{username} and u_password=#{password}")
    @Results(
            {
            @Result(column="u_userId",  property="uUserid" ),
            @Result( column="u_userName" , property="uUsername" ),
            @Result( column="u_password", property="uPassword" ),
            @Result( column="u_sex" , property="uSex" ),
            @Result( column="u_realName" , property="uRealname" ),
            @Result( column="u_birthday",property="uBirthday" ),
            @Result( column="u_email", property="uEmail" ),
            @Result( column="u_city" , property="uCity" ),
            @Result( column="u_address" , property="uAddress" ),
            @Result( column="u_phone",property="uPhone" ),
            @Result( column="u_createDate" ,property="uCreatedate" ),
            @Result( column="u_imgPath", property="uImgpath"),
            } )
    User logion(@Param("username")String username, @Param("password")String password);

    @Select("select * from user where u_userId=#{id}")
    @Results(
            {
            @Result(column="u_userId",  property="uUserid" ),
            @Result( column="u_userName" , property="uUsername" ),
            @Result( column="u_password", property="uPassword" ),
            @Result( column="u_sex" , property="uSex" ),
            @Result( column="u_realName" , property="uRealname" ),
            @Result( column="u_birthday",property="uBirthday" ),
            @Result( column="u_email", property="uEmail" ),
            @Result( column="u_city" , property="uCity" ),
            @Result( column="u_address" , property="uAddress" ),
            @Result( column="u_phone",property="uPhone" ),
            @Result( column="u_createDate" ,property="uCreatedate" ),
            @Result( column="u_imgPath", property="uImgpath"),
                    @Result(property = "receiveAddressList",column = "u_userId",
                            one =@One(select = "com.xuetang9.t9.xinhuaxia.mappers.ReceiveAddressMapper.queryByUserId")),
            } )
    User queryByUserId(@Param("id")Long id);
}